package com.ruoyi.web.controller.common.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ErpRetion;
import com.ruoyi.system.service.IErpRetionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 滞留件管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-24
 */
@RestController
@RequestMapping("/system/retion")
public class ErpRetionController extends BaseController
{
    @Autowired
    private IErpRetionService erpRetionService;

    /**
     * 查询滞留件管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:retion:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpRetion erpRetion)
    {
        startPage();
        List<ErpRetion> list = erpRetionService.selectErpRetionList(erpRetion);
        return getDataTable(list);
    }

    /**
     * 导出滞留件管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:retion:export')")
    @Log(title = "滞留件管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpRetion erpRetion)
    {
        List<ErpRetion> list = erpRetionService.selectErpRetionList(erpRetion);
        ExcelUtil<ErpRetion> util = new ExcelUtil<ErpRetion>(ErpRetion.class);
        util.exportExcel(response, list, "滞留件管理数据");
    }

    /**
     * 获取滞留件管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:retion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(erpRetionService.selectErpRetionById(id));
    }

    /**
     * 新增滞留件管理
     */
//    @PreAuthorize("@ss.hasPermi('system:retion:add')")
    @Log(title = "滞留件管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpRetion erpRetion)
    {
        return toAjax(erpRetionService.insertErpRetion(erpRetion));
    }

    /**
     * 修改滞留件管理
     */
//    @PreAuthorize("@ss.hasPermi('system:retion:edit')")
    @Log(title = "滞留件管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpRetion erpRetion)
    {
        return toAjax(erpRetionService.updateErpRetion(erpRetion));
    }

    /**
     * 删除滞留件管理
     */
//    @PreAuthorize("@ss.hasPermi('system:retion:remove')")
    @Log(title = "滞留件管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(erpRetionService.deleteErpRetionByIds(ids));
    }
}
